﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Networking;
using Interfaces;

namespace GUI
{
    public partial class Form1 : Form
    {

        ServerController controller = new ServerController();
        private Int32 _id;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnByd_Click(object sender, EventArgs e)
        {
            _id = Convert.ToInt32(listView1.SelectedItems[0].Text);
            controller.Byd(_id, Convert.ToDouble(txbPris));
            MessageBox.Show("Dit bud er nu blevet sendt af sted");

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            Refresh();
        }

        private void Refresh()
        {
            IEnumerator iEnumerator = controller.GetAuktioner();
            iEnumerator.Reset();
            listView1.Clear();
            while (iEnumerator.MoveNext())
            {
                IAuktion data = (IAuktion)iEnumerator.Current;
                ListViewItem linie = new ListViewItem();
                linie.Text = data.Nummer.ToString();
                linie.SubItems.Add(data.Navn);
                linie.SubItems.Add(data.Ting);
                linie.SubItems.Add(data.Pris.ToString());
                linie.SubItems.Add(data.Sluttid.ToString());
                listView1.Items.Add(linie);
            }
        }

        private void btn_Refresh(object sender, EventArgs e)
        {
            Refresh();
        }


    }
}
